<?php

/**
 * 广告模型
 * File Name：AdvertisingModel.php
 * File Encoding：UTF-8
 * File New Time：2014-5-29 9:29:34
 * Author：水平凡
 * Mailbox：admin@abc3210.com
 */
class AdvertisingModel extends BaseModel {

    public function tableName() {
        return '{{advertising}}';
    }

    public function rules() {
        return array(
            array('link_title', 'required', 'message' => '广告名称不能为空！'),
            array('link_img', 'required', 'message' => '广告图片不能为空！'),
            array('link', 'required', 'message' => '广告地址不能为空！'),
            array('width', 'required', 'message' => '宽度不能为空！'),
            array('height', 'required', 'message' => '高度不能为空！'),
            array('start_time', 'required', 'message' => '开始时间不能为空！'),
            array('end_time', 'required', 'message' => '结束时间不能为空！'),
            array('level,listorder,description,disabled,position', 'safe'),
        );
    }

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    //数据保存前操作
    protected function beforeSave() {
        //时间处理
        if (!is_numeric($this->start_time)) {
            $this->start_time = strtotime($this->start_time);
        }
        if (!is_numeric($this->end_time)) {
            $this->end_time = strtotime($this->end_time);
        }
        //是否新增
        if ($this->isNewRecord) {
            
        } else {
            
        }
        return true;
    }

}
